package com.slsoft.sys.dao;

import javax.persistence.QueryHint;

import org.springframework.data.jpa.repository.Query;
import org.springframework.data.jpa.repository.QueryHints;
import org.springframework.data.repository.query.Param;
import org.springframework.stereotype.Repository;

import cn.fastmc.code.jpa.dao.SpringJpaDao;

import com.slsoft.sys.entify.Menu;

@Repository
public interface MenuDao extends SpringJpaDao<Menu, String> {

    @Query("from Menu order by orderRank ")
    @QueryHints({ @QueryHint(name = org.hibernate.ejb.QueryHints.HINT_CACHEABLE, value = "true") })
    public Iterable<Menu> findAllCached();
    
    @Query("select count(id) from Menu where parent=:parent")
    public long findChildrenSize(@Param("parent") Menu parent);
}
